# 使用while和for…in两个循环分别输出四种九九乘法表效果

# 九九乘法表,for in 输出,左对齐正序
def getJJListByLeftAsc():
    '''
    九九乘法表,for in 输出,左对齐正序
    '''
    print("="*12,"for in 输出,左对齐正序","="*12)
    for i in range(1,10):
        for j in range(1,i+1):
            print("{}*{}={:<2}".format(j,i,i*j),end=" ")
        print("")

# 九九乘法表,for in 输出,左对齐倒序
def getJJListByLeftDesc():
    '''
    九九乘法表,for in 输出,左对齐倒序
    '''
    print("="*12,"for in 输出，左对齐倒序","="*12)
    for i in range(9,0,-1):
        for j in range(1,i+1):
            print("{}*{}={:<2}".format(j,i,i*j),end="  ")
        print("")

# 九九乘法表,for in 输出,右对齐正序
def getJJListByRightAsc():
    '''
    九九乘法表,for in 输出,右对齐正序
    '''
    print("="*12,"for in 输出，右对齐正序","="*12)
    for i in range(1,10):
        tempstr=""
        for j in range(i,0,-1):
            tempstr+="  {}*{}={:<2}".format(j,i,i*j)
        n=(9-i)*8
        print(" "*n,tempstr)

# 九九乘法表,for in 输出,右对齐倒序
def getJJListByRightDesc():
    '''
    九九乘法表,for in 输出,右对齐倒序
    '''
    print("="*12,"for in 输出，右对齐倒序","="*12)
    for i in range(9,0,-1):
        tempstr = ""
        for j in range(i,0,-1):
            tempstr+= "  {}*{}={:<2}".format(j, i, i * j)
        n = (9 - i) * 8
        print(" " * n, tempstr)

# 九九乘法表,while 输出,左对齐正序
def getJJListByWhileLeftAsc():
    '''
    九九乘法表,while 输出,左对齐正序
    '''
    print("="*12,"while 输出,左对齐正序","="*12)
    i=1
    while i<=9:
        j=1
        while j<=i:
            print("{}*{}={:<2}".format(i,j,i*j),end=" ")
            j+=1
        print("")
        i+=1

# 九九乘法表,while 输出,左对齐倒序
def getJJListByWhileLeftDesc():
    '''
    九九乘法表,while 输出,左对齐倒序
    '''
    print("="*12,"while 输出,左对齐倒序","="*12)
    i=9
    while i>=1:
        j=i
        while j>=1:
            print("{}*{}={:<2}".format(i,j,i*j),end=" ")
            j-=1
        print("")
        i-=1

# 九九乘法表,while 输出,右对齐正序
def getJJListByWhileRightAsc():
    '''
    九九乘法表,while 输出,右对齐正序
    '''
    print("="*12,"while 输出,右对齐正序","="*12)
    i=1
    while i<=9:
        j=1
        tempstr=""
        while j<=i:
            tempstr+="  {}*{}={:<2}".format(i,j,i*j)
            j+=1
        n=(9-i)*8
        print(" "*n,tempstr)
        i+=1

# 九九乘法表,while 输出,右对齐倒序
def getJJListByWhileRightDesc():
    '''
    九九乘法表,while 输出,右对齐倒序
    '''
    print("="*12,"while 输出,右对齐倒序","="*12)
    i=9
    while i>=1:
        j=i
        tempstr = ""
        while j>=1:
            tempstr += "  {}*{}={:<2}".format(i, j, i * j)
            j-=1
        n = (9 - i) * 8
        print(" " * n, tempstr)
        i-=1

getJJListByLeftAsc()# 九九乘法表,for in 输出,左对齐正序
getJJListByLeftDesc()# 九九乘法表,for in 输出,左对齐倒序
getJJListByRightAsc()# 九九乘法表,for in 输出,右对齐正序
getJJListByRightDesc()# 九九乘法表,for in 输出,右对齐倒序
getJJListByWhileLeftAsc()# 九九乘法表,while 输出,左对齐正序
getJJListByWhileLeftDesc()# 九九乘法表,while 输出,左对齐倒序
getJJListByWhileRightAsc()# 九九乘法表,while 输出,右对齐正序
getJJListByWhileRightDesc()# 九九乘法表,while 输出,右对齐倒序